package org.msfj.admin.model;

import org.msfj.common.base.BaseModel;

import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

@Table(name = "admin_user")
public class User extends BaseModel implements Serializable {
    /**
     * 登陆帐户
     */
    @Column(name = "account_")
    private String account;

    /**
     * 密码
     */
    @Column(name = "password_")
    private String password;

    /**
     * 旧密码盐
     */
    @Column(name = "old_salt")
    private String oldSalt;

    /**
     * 电话
     */
    @Column(name = "phone_")
    private String phone;

    /**
     * 性别(0:未知;1:男;2:女)
     */
    @Column(name = "sex_")
    private Integer sex;

    /**
     * 姓名
     */
    @Column(name = "name_")
    private String name;

    /**
     * 头像
     */
    @Column(name = "avatar_")
    private String avatar;

    /**
     * 部门编号
     */
    @Column(name = "dept_id")
    private String deptId;

    /**
     * 工号
     */
    @Column(name = "emp_no")
    private String empNo;



    /**
     * 获取登陆帐户
     *
     * @return account_ - 登陆帐户
     */
    public String getAccount() {
        return account;
    }

    /**
     * 设置登陆帐户
     *
     * @param account 登陆帐户
     */
    public void setAccount(String account) {
        this.account = account == null ? null : account.trim();
    }

    /**
     * 获取密码
     *
     * @return password_ - 密码
     */
    public String getPassword() {
        return password;
    }

    /**
     * 设置密码
     *
     * @param password 密码
     */
    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    /**
     * 获取电话
     *
     * @return phone_ - 电话
     */
    public String getPhone() {
        return phone;
    }

    /**
     * 设置电话
     *
     * @param phone 电话
     */
    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    /**
     * 获取性别(0:未知;1:男;2:女)
     *
     * @return sex_ - 性别(0:未知;1:男;2:女)
     */
    public Integer getSex() {
        return sex;
    }

    /**
     * 设置性别(0:未知;1:男;2:女)
     *
     * @param sex 性别(0:未知;1:男;2:女)
     */
    public void setSex(Integer sex) {
        this.sex = sex;
    }

    /**
     * 获取姓名
     *
     * @return name_ - 姓名
     */
    public String getName() {
        return name;
    }

    /**
     * 设置姓名
     *
     * @param name 姓名
     */
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    /**
     * 获取头像
     *
     * @return avatar_ - 头像
     */
    public String getAvatar() {
        return avatar;
    }

    /**
     * 设置头像
     *
     * @param avatar 头像
     */
    public void setAvatar(String avatar) {
        this.avatar = avatar == null ? null : avatar.trim();
    }

    /**
     * 获取部门编号
     *
     * @return dept_id - 部门编号
     */
    public String getDeptId() {
        return deptId;
    }

    /**
     * 设置部门编号
     *
     * @param deptId 部门编号
     */
    public void setDeptId(String deptId) {
        this.deptId = deptId;
    }


    public String getEmpNo() {
        return empNo;
    }

    public void setEmpNo(String empNo) {
        this.empNo = empNo;
    }

    public String getOldSalt() {
        return oldSalt;
    }

    public void setOldSalt(String oldSalt) {
        this.oldSalt = oldSalt;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(account, user.account) &&
                Objects.equals(password, user.password) &&
                Objects.equals(oldSalt, user.oldSalt) &&
                Objects.equals(phone, user.phone) &&
                Objects.equals(sex, user.sex) &&
                Objects.equals(name, user.name) &&
                Objects.equals(avatar, user.avatar) &&
                Objects.equals(deptId, user.deptId) &&
                Objects.equals(empNo, user.empNo);
    }

    @Override
    public int hashCode() {

        return Objects.hash(account, password, oldSalt, phone, sex, name, avatar, deptId, empNo);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", account=").append(account);
        sb.append(", password=").append(password);
        sb.append(", phone=").append(phone);
        sb.append(", sex=").append(sex);
        sb.append(", name=").append(name);
        sb.append(", avatar=").append(avatar);
        sb.append(", empNo=").append(empNo);
        sb.append(", deptId=").append(deptId);

        sb.append("]");
        return sb.toString();
    }
}
